<?php

namespace App\Models\Admin\Framework;

use App\Models\Arts\UserModel;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class AdminRoleModel extends Model
{
    use HasFactory;

    protected $table = 'admin_role';
    public $timestamps = false;


    public static function getRoleParentsTree(){
        $roles = self::query()->where(['status'=>1,'is_show'=>1])
            ->select(['id as value', 'name as label'])
            ->orderBy('id', 'asc')->get()->toArray();
        if(empty($roles)){
            return [];
        }
        return $roles;
    }

    public function group()
    {
        return $this->hasOne(AdminGroupModel::class, 'id', 'group_id');
    }
}
